﻿namespace ChinaUnicom.ViewModels
{
    using ChinaUnicom.Models;
    using System.Linq;

    public static class FeeHistoryCollectionExtensions
    {
        public static void Partial(this FeeHistoryCollection collection, FeeHistoryCollection items, int take = 20)
        {
            if (collection == null || items == null) return;

            var histories = from f in items
                            orderby f.Occurred descending
                            select f;

            foreach (var item in histories.Take(take))
            {
                collection.Add(item);
            }

            if (items.Count > take)
            {
                collection.HasMore = true;
            }
        }
    }
}
